package ro.toporjinschi.anytaxi.database.lists;

import java.util.ArrayList;
import java.util.List;

import ro.toporjinschi.anytaxi.database.DatabaseAccess;
import ro.toporjinschi.anytaxi.database.beans.Place;
import android.content.Context;
import android.widget.ArrayAdapter;

public class PlacesList {
    private DatabaseAccess db;

    public PlacesList(DatabaseAccess db) {
        this.db = db;
    }

    public List<Place> getPlaces() {
//        Cursor placesCursor = db.getReadableDatabase().rawQuery(Place.FIND_ALL, null);
        List<Place> places = new ArrayList<Place>();
//        while (placesCursor.moveToNext()) {
//            Place place = new Place();
//            place.setId(placesCursor.getInt(0));
//            place.setTown(placesCursor.getString(1));
//            place.setStreat(placesCursor.getString(2));
//            place.setNo(placesCursor.getInt(3));
//            place.setBilding(placesCursor.getString(4));
//            place.setStairs(placesCursor.getString(5));
//            place.setZipCode(placesCursor.getInt(6));
//            place.setDetails(placesCursor.getString(7));
//            places.add(place);
//        }
        return places;
    }

    public Place getPlace(int id) {
//        Cursor placesCursor = db.getReadableDatabase().rawQuery(Place.FIND_BY_ID, new String[] { Integer.toString(id) });
        Place place = new Place();
//        if (placesCursor.moveToNext()) {
//            place.setId(placesCursor.getInt(0));
//            place.setTown(placesCursor.getString(1));
//            place.setStreat(placesCursor.getString(2));
//            place.setNo(placesCursor.getInt(3));
//            place.setBilding(placesCursor.getString(4));
//            place.setStairs(placesCursor.getString(5));
//            place.setZipCode(placesCursor.getInt(6));
//            place.setDetails(placesCursor.getString(7));
//        }
        return place;
    }

    public ArrayAdapter<Place> getPlacesArrayAdapter(Context context, int layerId) {
        return new ArrayAdapter<Place>(context, layerId, this.getPlaces());
    }

    public ArrayAdapter<Place> getPlacesArrayAdapter(Context context) {
        return getPlacesArrayAdapter(context, android.R.layout.simple_list_item_1);
    }
}